﻿namespace NetBrother.TopShow
{
    using System.Collections.Generic;

    using IBatisNet.DataMapper;
    using IBatisNet.DataMapper.Configuration;
    using System;

    public class MyBatisMapperManager
    {
        // Fields
        private static readonly object locker;
        private static readonly IDictionary<string, ISqlMapper> mappers;

        // Methods
        static MyBatisMapperManager()
        {
            locker = new object();
            mappers = new Dictionary<string, ISqlMapper>();
            return;
        }

        public MyBatisMapperManager()
        {
        }

        public static ISqlMapper GetMapper(string name)
        {
            DomSqlMapBuilder d = new DomSqlMapBuilder();//³õÊ¼»¯Ò»¸öDomSqlMapBuilder
            ISqlMapper sm = d.Configure(name);          //µ÷ÓÃConfigure·½·¨²¢Ö¸¶¨ÅäÖÃÎÄ¼þµÄÃû³Æ,·µ»ØÒ»¸öSqlMapper
            return sm;

        }

        public static ISqlMapper GetMapper(Uri resource)
        {
            DomSqlMapBuilder d = new DomSqlMapBuilder();//³õÊ¼»¯Ò»¸öDomSqlMapBuilder
            ISqlMapper sm = d.Configure(resource);          //µ÷ÓÃConfigure·½·¨²¢Ö¸¶¨ÅäÖÃÎÄ¼þµÄÃû³Æ,·µ»ØÒ»¸öSqlMapper
            return sm;
        }
    }
}

